<div class="row" id="data-admin-id" data-admin-id="<?php echo $result['id'];?>">
<div class="col-xs-12">
	
	<form class="form-horizontal" role="form"  action="<?php echo DOMAIN_ADMIN?>/manage/edit/<?php echo $result['id'];?>" method="post"  id='add_user_submit'>

		<input type="hidden" name="id" value="<?php echo $result['id'];?>">
		
		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right" for="data-admin-username">
			<span class="red">*</span>登录账号：
			</label>
			<div class="col-sm-9">
		    <input type="text" class="col-xs-10 col-sm-5"  name="username"  id="data-admin-username"
				   value="<?php echo $result['username']?>" required maxlength="20">
			<label class="red" id="data-role-name-error"><?php echo form_error('username')?></label>
			</div>
		</div>
		<div class="space-4"></div>

		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right" for="data-admin-pass">
		    <span class="red">*</span>密码：
		    </label>
			<div class="col-sm-9">
				<input type="password" class="col-xs-10 col-sm-5" name="pass"  id="data-admin-pass"
					   value="" required>
				<label class="red" id="data-role-pass-error"><?php echo form_error('pass')?></label>
			</div>
		</div>
		<div class="space-4"></div>


		<div class="form-group">
			
			<label class="col-sm-3 control-label no-padding-right" for="data-admin-nickname">管理员昵称：</label>
			
			<div class="col-sm-9">
				<input type="text" class="col-xs-10 col-sm-5"  name="nickname"  id="data-admin-username"
						   value="<?php echo $result['nickname']?>" maxlength="40">
				<label class="red" id="data-role-nickname-error"><?php echo form_error('nickname')?></label>
			</div>
		</div>
		<div class="space-4"></div>
			
		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right">
			<span class="red">*</span>管理员角色：
			</label>
			
			<div class="col-sm-4">
			    <select class="form-control" name='rid'>
			        <?php foreach( $roles as $e ):?>
					<option value=<?php echo $e['id']?> <?php if( $e['id'] == $result['rid']) echo "selected";?>><?php echo $e['name']?></option>
					<?php endforeach;?>
			    </select>
				
				<label class="red"><?php echo form_error('rid')?></label>
			</div>
		</div>
		
		<div class="clearfix form-actions">
			<div class="col-md-offset-3 col-md-9">
				<button class="btn btn-info btn-sm" type="submit">
					<i class="ace-icon fa fa-check bigger-110"></i>
					提交
				</button>

				&nbsp; &nbsp; &nbsp;
				<button class="btn btn-sm" type="reset">
					<i class="ace-icon fa fa-undo bigger-110"></i>
					重置
				</button>
			</div>
		</div>
	
	</form>
	
</div>
</div>

<script type="text/javascript">

	$(document).on('keyup', '#data-admin-username', function () {

		var admin_name=$('#data-admin-username').val();
		var admin_id=$('#data-admin-id').attr('data-admin-id');
		var url='<?php echo DOMAIN_MAIN?>/api/permissions/check_admin_name';
		var params={
			admin_name:admin_name,
			admin_id:admin_id
		};

		$.get(url, params, function (data) {
			if(data.state=='success'){
				var new_dom='管理员名称已存在，请重新填写！';
				$("#data-role-name-error").html(new_dom);
				return false;
			}else{
				$("#data-role-name-error").html('');
				return true;
			}

		},'json');



	});

	$(document).on('keyup', '#data-admin-pass', function () {

		var admin_pass=$('#data-admin-pass').val();
		var url='<?php echo DOMAIN_MAIN?>/api/permissions/check_admin_pass';
		var params={
			admin_pass:admin_pass
		};

		$.get(url, params, function (data) {
			if(data.state=='success'){
				if(data.error_type==1){
					var new_dom='管理员密码须大于6位，请继续输入！';
				}else if(data.error_type==2){
					var new_dom='管理员密码须小于30位，请重新填写！';
				}

				$("#data-role-pass-error").html(new_dom);
				return false;
			}else{
				$("#data-role-pass-error").html('');
				return true;
			}

		},'json');



	});
</script>